package org.czl.gh;

import java.util.ArrayList;
import java.util.List;

public class l489 {
    public static void main(String[] args) {
        List<Integer> list = new ArrayList<>();
        list.add(3);
        list.add(4);
        list.add(1);
        findMinimumTime(list, 1);
    }
    static int KK;
    public static int findMinimumTime(List<Integer> strength, int K){
        KK = K;
        int[] dp = new int[1 << strength.size()];
        int ini = (1 << strength.size()) - 1;
        return f(ini , strength, 1, dp);
    }
    static int f(int status, List<Integer> strength, int k, int[] dp){
        if(status == 0){
            return 0;
        }
        if(dp[status] != 0)return dp[status];

        int ans = Integer.MAX_VALUE;
        int n = strength.size();
        for(int i = 0; i < n; i++){
            if(((1 << i) & status) != 1){
                int co = strength.get(i) % k == 0 ? strength.get(i) / k : strength.get(i) / k + 1;
                ans = Math.min(f(status ^ (1 << i), strength,KK + k, dp) + co, ans);
            }
        }
        dp[status] = ans;
        return dp[status];
    }
}
